from abc import ABC, abstractmethod

class BaseConverter(ABC):
    def __init__(self, wsl_file_path, temp_dir, log_callback):
        self.wsl_file_path = wsl_file_path
        self.temp_dir = temp_dir
        self.log = log_callback

    @abstractmethod
    def convert(self):
        pass

    def run_wsl_command(self, cmd):
        # 通用命令执行逻辑
        process = subprocess.Popen(
            cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True
        )
        for line in process.stdout:
            self.log(line)
        process.wait()
        if process.returncode != 0:
            raise subprocess.CalledProcessError(process.returncode, cmd)